-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if path exists before creating FileInfo #8840
Check if path exists before creating FileInfo #8840
Conversation
Will avoid exceptions for illegal characters etc
Codecov Report
@@ Coverage Diff @@
## master #8840 +/- ##
==========================================
+ Coverage 56.10% 56.11% +0.01%
==========================================
Files 919 919
Lines 65522 65521 -1
Branches 11997 11996 -1
==========================================
+ Hits 36760 36770 +10
+ Misses 25759 25752 -7
+ Partials 3003 2999 -4
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a question
if (string.IsNullOrWhiteSpace(filePath)) | ||
{ | ||
continue; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other changes make sense, but this change is surprising in the given context. Could you please elaborate on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null annotation is coming soon...
null is an acceptable input with the change so the caller do not need to check
Will avoid exceptions for illegal characters etc
Fixes #8839
Proposed changes
Use File.Exists(path) before FileInfo(path) to avoid exceptions.
Can be seen as a follow up to #8575
Test methodology
review
✒️ I contribute this code under The Developer Certificate of Origin.